package com.hivekion.quartz.listener;

import com.hivekion.quartz.service.IQuartzService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationListener;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.event.ContextRefreshedEvent;

/**
 * @authot morning
 * @date 2021/8/4 9:58 监听启动
 */
@Configuration
public class ApplicationStartListener implements ApplicationListener<ContextRefreshedEvent> {

    private static Logger log = LoggerFactory.getLogger(ApplicationStartListener.class);
    @Autowired
    private IQuartzService quartzService;

    @Override
    public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
//        JobSearchPageVo vo = new JobSearchPageVo();
//        vo.setPageNum(1);
//        vo.setPageSize(500);
//        PagedResultVo<JobViewVo> resultVo = quartzService.queryList(vo);
//        if (resultVo.getData() != null && resultVo.getData().size() > 0) {
//            resultVo.getData()
//                    .forEach(
//                            item -> {
//                                quartzService.startJob(item.getId());
//                            });
//        }
        log.info("***数据库任务加载完成。。。");
        log.info("************application已经启动完毕************");
    }
}
